package com.honey.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.honey.entity.AjaxResult;
import com.honey.entity.TwoCode;
import com.honey.service.TwoCodeService;
/**
 * 
 * @author honey
 *
 */
@Controller
public class TwoCodeController {

	@Autowired
	TwoCodeService twoCodeService;
	
	@RequestMapping("/toCode")
	@ResponseBody
	public AjaxResult createTwoCode(TwoCode twoCode) {
		System.out.println(twoCode);
		twoCodeService.twoCodeCreate(twoCode);
		return AjaxResult.success();
	}
	
	@PostMapping("/toCodeBuf")
	@ResponseBody
	public AjaxResult twoCodeBuf(TwoCode twoCode) {
		System.out.println(twoCode);
		String img = twoCodeService.imgToBuf(twoCode);
		return AjaxResult.success("处理成功","data:image/png;base64,"+img);
	}
	
	@GetMapping("/index")
	public String index() {
		return "index";
	}
}
